<?php

/*

  Action	$3

  Choose one: +2 Cards; or +$2; or trash 2 cards from your hand.

 */

class Steward extends Card implements iAction, iKingdom, iIntrigue {

    public function __construct() {
        parent::__construct("Steward", 3);
        $this->undoPlay = false;
        $this->undoBuy = true;
    }

    public function getDescription() {
        return array(
            "Choose one: +2 Cards; or +$2; or trash 2 cards from your hand.");
    }
    
    public function play(Game $game, $isRealCard) {
        $options = array(new Option(1, "2 Cards"), new Option(2, "2$"), new Option(2, "trash 2 cards"));

        $output = MySocket::GetUserReply($game, Input_ChooseOne, $options, 1, 1, null, "Please choose");
        $answer = $output[0];
        if ($answer == "2 Cards") {
            $drawed_cards = $game->drawCards(2);
             ScreenDisplay::addScreenMessage($game, true, "draw " . nicePrint($drawed_cards) , "draws " . sizeof($drawed_cards) . " cards");
        } elseif ($answer == "trash 2 cards") {

            $playHand = $game->getPlayHand();
            if ($playHand > 2) {
                $output = MySocket::GetUserReply($game, Input_ChooseMany, $playHand, 2, 2, null, "Choose 2 cards to trash");
                  ScreenDisplay::addScreenMessage($game, true, "trash ". nicePrint($output), "trashes ".ScreenDisplay::$LMSG);
                foreach ($output as $card_name) {
                    $game->moveCardFromPileToPile($card_name, PlayHand, Trash);
                }
            } else {
                 ScreenDisplay::addScreenMessage($game, true, "trash ". nicePrint($playHand), "trashes ".ScreenDisplay::$LMSG);
                foreach ($playHand as $card) {
                    $game->moveCardFromPileToPile($card, PlayHand, Trash);
                }
            }
        } else {
            $game->addMoney(2);
              ScreenDisplay::addScreenMessage($game, true, "get +2$", "gets +2$");
        }
        $game->cardActionFinished();
        return true;
    }

}

?>